package a.e;

import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class n
  extends k
{
  private float g = 1.0F;
  static Class h;
  static Class i;
  public static int j;
  
  public n()
  {
    super(true);
  }
  
  public String a()
  {
    return "JPG Format";
  }
  
  public String b()
  {
    return "jpg";
  }
  
  protected BufferedImage a(int paramInt1, int paramInt2)
  {
    return new BufferedImage(paramInt1, paramInt2, 1);
  }
  
  protected void a(BufferedImage paramBufferedImage, OutputStream paramOutputStream)
    throws IOException
  {
    int k = e.b;
    ImageWriter localImageWriter = m.c("jpeg");
    Object localObject1;
    if ((k != 0) || (localImageWriter != null))
    {
      localObject1 = localImageWriter.getDefaultWriteParam();
      if (k == 0)
      {
        if (((ImageWriteParam)localObject1).canWriteCompressed())
        {
          ((ImageWriteParam)localObject1).setCompressionMode(2);
          ((ImageWriteParam)localObject1).setCompressionQuality(this.g);
        }
        m.a(localImageWriter, paramBufferedImage, paramOutputStream, (ImageWriteParam)localObject1);
      }
      if (e.a == 0) {}
    }
    else
    {
      try
      {
        localObject1 = Class.forName("com.sun.image.codec.jpeg.JPEGCodec");
        Class[] tmp79_76 = new Class[1];
        if (k == 0) {}
        tmp79_76[0] = (h == null ? (n.h = c("java.io.OutputStream")) : h);
        localObject2 = tmp79_76;
        localObject3 = ((Class)localObject1).getMethod("createJPEGEncoder", (Class[])localObject2);
        Object[] arrayOfObject = { paramOutputStream };
        Object localObject4 = ((Method)localObject3).invoke(null, arrayOfObject);
        Class localClass1 = Class.forName("com.sun.image.codec.jpeg.JPEGImageEncoder");
        if (k == 0) {}
        localObject2[0] = (i == null ? (n.i = c("java.awt.image.BufferedImage")) : i);
        Method localMethod1 = localClass1.getMethod("getDefaultJPEGEncodeParam", (Class[])localObject2);
        arrayOfObject[0] = paramBufferedImage;
        Object localObject5 = localMethod1.invoke(localObject4, arrayOfObject);
        Class localClass2 = Class.forName("com.sun.image.codec.jpeg.JPEGEncodeParam");
        localObject2 = new Class[2];
        localObject2[0] = Float.TYPE;
        localObject2[1] = Boolean.TYPE;
        Method localMethod2 = localClass2.getMethod("setQuality", (Class[])localObject2);
        arrayOfObject = new Object[2];
        arrayOfObject[0] = new Float(this.g);
        arrayOfObject[1] = Boolean.TRUE;
        localMethod2.invoke(localObject5, arrayOfObject);
        if (k == 0) {}
        localObject2[0] = (i == null ? (n.i = c("java.awt.image.BufferedImage")) : i);
        localObject2[1] = localClass2;
        Method localMethod3 = localClass1.getMethod("encode", (Class[])localObject2);
        arrayOfObject[0] = paramBufferedImage;
        arrayOfObject[1] = localObject5;
        localMethod3.invoke(localObject4, arrayOfObject);
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        localObject2 = new IOException(i());
        ((IOException)localObject2).initCause(localClassNotFoundException);
        throw ((Throwable)localObject2);
      }
      catch (NoSuchMethodException localNoSuchMethodException)
      {
        localObject2 = new IOException(i());
        ((IOException)localObject2).initCause(localNoSuchMethodException);
        throw ((Throwable)localObject2);
      }
      catch (InvocationTargetException localInvocationTargetException)
      {
        localObject2 = localInvocationTargetException.getCause();
        if ((k != 0) || ((localObject2 instanceof IOException))) {
          throw ((IOException)localObject2);
        }
        Object localObject3 = new IOException(i());
        ((IOException)localObject3).initCause((Throwable)localObject2);
        throw ((Throwable)localObject3);
      }
      catch (IllegalAccessException localIllegalAccessException)
      {
        Object localObject2 = new IOException(i());
        ((IOException)localObject2).initCause(localIllegalAccessException);
        throw ((Throwable)localObject2);
      }
    }
  }
  
  private static String i()
  {
    return m.d("jpeg");
  }
  
  public void a(float paramFloat)
  {
    this.g = paramFloat;
  }
  
  public float j()
  {
    return this.g;
  }
  
  static Class c(String paramString)
  {
    try
    {
      return Class.forName(paramString);
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.e.n

 * JD-Core Version:    0.7.0.1

 */